
<?php

global $post;

wp_nonce_field( plugin_basename( __FILE__ ), COOL_DIAEY_PRIFIX.'wpnonce', false, true );

$data = get_post_meta($post->ID, COOL_DIAEY ,true);

if(empty($data['city'])){

	$weather_config = get_option('coolDiary');

	include_once('function.php');
	if($weather_config['weather']['method']=='city'){
		$city = $weather_config['weather']['city'];

	}
	else{
		$ip = getIPPlace();
		$city = $ip[3];
		$city =trim($city);
		$city2=trim($ip[2]);
		$city = isset($city)?$city:isset($city2)?$city2:'深圳';

	}
	$weather = get_weather($city);

	$data['weather'] = $weather['today']['conditions'];
	$data['city'] = $city;
	$data['mood'] = 'happy';
}



?>

<div>城市:<input style="width: 60px; border: none" id="coolDiary_city" name="coolDiary_city"
	type="text" value="<?php echo $data['city'] ?>" size="10" /><a href="#"
	id="weather_update">更新天气</a><br />

天气:<input style="width: 100px; border: none" name="coolDiary_weather"
	type="text" id="coolDiary_weather"
	value="<?php echo $data['weather']?>" size="10" /> <br />
心情:<input style="width: 60px; border: none" name="coolDiary_mood"
	type="text" value="<?php echo $data['mood'] ?>" size="10" />
<p></p>

</div>






